package per.sunmes.lesrb.util;

import java.util.Calendar;

public class TimeUtil {

	public static Calendar tmpCalendar = Calendar.getInstance();

	public static boolean isToday(long time) {
		Calendar now = Calendar.getInstance();
		tmpCalendar.setTimeInMillis(time);
		if (now.get(Calendar.YEAR) == tmpCalendar.get(Calendar.YEAR)
				&& now.get(Calendar.DAY_OF_YEAR) == tmpCalendar.get(Calendar.DAY_OF_YEAR)) {
			return true;
		}
		return false;
	}

	/**
	 * format secord float value to 00:00 string.
	 * 
	 * @param dt
	 * @return
	 */
	public static String formatMMSS(float dt) {
		int second = (int) (Math.ceil(dt % 60));
		int minus = (int) (dt / 60);
		if (second == 60) {
			second = 0;
			minus++;
		}
		return StringUtil.format("%02d:%02d", minus, second);
	}

}
